/*
 * Copyright (c) 2025.
 * All rights reserved.
 */

#ifndef _PC_FT_IOCTL_COMMUNICATOR_H_
#define _PC_FT_IOCTL_COMMUNICATOR_H_

#include <ntddk.h>
#include "message.h"

typedef VOID MSG_RECV_FUNC(
    SHORT Message
);
typedef MSG_RECV_FUNC* PMSG_RECV_FUNC;

typedef struct _MSG_ITEM {
    CHAR   Id;
    CHAR   State;
    KEVENT  Event;
    SHORT   Message;
} MSG_ITEM, * PMSG_ITEM;

typedef struct _MSG_PARAM {
    SHORT type;
    PCUNICODE_STRING filePath;
    HANDLE pid;
    HANDLE parentPid;
} MSG_PARAM, * PMSG_PARAM;

/// <summary>
/// Init callback and local state
/// </summary>
/// <param name="driverObject"></param>
/// <param name="msgRecvFunc"></param>
/// <returns></returns>
NTSTATUS IoctlLoad(
    _In_ PDRIVER_OBJECT driverObj,
    _In_ PMSG_RECV_FUNC msgRecvFunc);
/// <summary>
/// Create communicate device.
/// </summary>
/// <param name="driverObject"></param>
/// <returns></returns>
NTSTATUS IoctlCreateDevice(
    _In_ PDRIVER_OBJECT driverObj);
VOID IoctlUnload(
    _In_ PDRIVER_OBJECT driverObj);
VOID SetMsgState(
    _In_ PMSG_ITEM pMsg,
    _In_ CHAR state);
NTSTATUS IoctlConnect(
    _In_ PDEVICE_OBJECT deviceObj,
    _In_ PIRP irp);
NTSTATUS IoctlDisconnect(
    _In_ PDEVICE_OBJECT deviceObj,
    _In_ PIRP irp);
NTSTATUS IoctlHandleMsg(
    _In_ PDEVICE_OBJECT deviceObj,
    _In_ PIRP irp);
BOOLEAN IoctlSendMsg(
    _In_ MSG_PARAM msgParam,
    _In_ BOOLEAN waitReply,
    _Out_ PMSG_ITEM* msgItem);

#endif // _PC_FT_IOCTL_COMMUNICATOR_H_
